#include <iostream>  
using namespace std;  
  
class CircularQueue {  
public:  
    CircularQueue(int k) {  
        capacity = k;  
        front = 0;  
        rear = 0;  
        count = 0;  
        queue = new int[capacity];  
    }  
  
    ~CircularQueue() {  
        delete[] queue;  
    }  
  
    bool isFull() {  
        return (count == capacity);  
    }  
  
    bool isEmpty() {  
        return (count == 0);  
    }  
  
    void enqueue(int value) {  
        if (isFull()) {  
            cout << "Queue is full. Can't enqueue." << endl;  
            return;  
        }  
        queue[rear] = value;  
        rear = (rear + 1) % capacity;  
        count++;  
    }  
  
    int dequeue() {  
        if (isEmpty()) {  
            cout << "Queue is empty. Can't dequeue." << endl;  
            return -1;  
        }  
        int value = queue[front];  
        front = (front + 1) % capacity;  
        count--;  
        return value;  
    }  
  
    int peek() {  
        if (isEmpty()) {  
            cout << "Queue is empty. Can't peek." << endl;  
            return -1;  
        }  
        return queue[front];  
    }  
  
private:  
    int capacity; // 队列容量  
    int front; // 队首指针  
    int rear; // 队尾指针  
    int count; // 队列元素个数  
    int* queue; // 队列数组指针  
};